<script type="text/javascript">

$(document).ready(function(){
	
	$("#btn_lihat_data_peserta").click(function(){
	alert("Peserta");
	});
	
	
	$("#btn_lihat_benefit").click(function(){
	var file = $("#nama_file").val();
	var klien = $("#mst_client_id").val();
	var w=800;
	var h=570;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	
	if(klien==''){
	alert("Pilih Klien Terlebih Dahulu");
	}
	else{
	var strWindowFeatures = "location=yes,height=570,width=800,scrollbars=yes,status=yes, top="+top+", left="+left;
	var URL = "<?php echo Yii::app()->request->baseUrl; ?>/upload/benefit_client/"+file;
	var win = window.open(URL, "_blank", strWindowFeatures);
	}
	});
	
	$("#body-claim").on('change','#plan','select',function(){
	var index = $(this).attr('index');
	var value = $(this).val();
	if(value=='IP'){
	$("#tgl_claim2"+index).show();
	}else{
	$("#tgl_claim2"+index).hide();
	}
	});
	
	
$("#btnTest").click(function()
{
	
   var nil = "";
   nil = $('input:radio[name=user]:checked').val()+" - "+$('input:radio[name=user]:checked').attr('nama_client');
   $("#policy_no").val(nil);
   $("#policy_no_hist_claim").val($('input:radio[name=user]:checked').val());
   $("#mst_client_id").val($('input:radio[name=user]:checked').attr('mst_client_id'));
   $("#reg_policy_id").val($('input:radio[name=user]:checked').attr('id_number'));
   $("#type_reg_policy").val($('input:radio[name=user]:checked').attr('typereg'));
   $("#nama_file").val($('input:radio[name=user]:checked').attr('nama_file'));
}); 

$("#btn_tambah").click(function(){

var index = parseInt($("#index").val());

var indexi = index+1;

var html = '<tr>'+
			'<td><span id="nomor">'+indexi+'</span></td>'+
			'<td>'+
				'<input type="text" maxlength="100" id="karyawan" name="karyawan[]" class="form-control input-width-medium">'+
			'</td>'+

			'<td>'+
				'<input type="text" maxlength="100" id="peserta" name="peserta[]" class="form-control input-width-medium">'+
			'</td>'+

			'<td>'+
				'<input type="text" maxlength="20" id="no_reg" name="no_reg[]" class="form-control input-width-small">'+
			'</td>'+


			'<td>'+
				'<input type="text" id="tgl_claim" name="tgl_claim[]" data-mask="99-99-9999" class="form-control input-width-small">'+
				'<div id="tgl_claim2'+indexi+'" style="text-align:center;">sd'+
				'<input type="text" id="tgl_claim2" name="tgl_claim2[]" data-mask="99-99-9999" class="form-control input-width-small">'+
				'</div>'+
			'</td>'+

			'<td>'+
			'<select id="plan" class="form-control input-width-small" name="plan[]" index="'+indexi+'">'+
			'<option value="IP">IP</option>'+
			'<option value="OP">OP</option>'+
			'<option value="MA">MA</option>'+
			'<option value="VS">VS</option>'+
			'<option value="DE">DE</option>'+
			'<option value="KECELAKAAN">KECELAKAAN</option>'+
			'<option value="JIWA">JIWA</option>'+
			'<option value="MEDEVAC">MEDEVAC</option>'+
			'<option value="JENAZAH">JENAZAH</option>'+
			'</select>'+
			'</td>'+

			'<td>'+
				'<input type="text" id="nominal" name="nominal[]" class="form-control input-width-small">'+
			'</td>'+

			'<td>'+
				'<input type="text" id="jumlah_dibayar" name="jumlah_dibayar[]" class="form-control input-width-small">'+
			'</td>'+

			'<td>'+
				'<input type="text" id="tgl_pembayaran" name="tgl_pembayaran[]" data-mask="99-99-9999" class="form-control input-width-small">'+
			'</td>'+

			'<td>'+
				'<textarea id="remarks" name="remarks[]" class="form-control input-width-large"></textarea>'+
			'</td>'+
			
			'<td>'+
				'<textarea id="kelengkapan_dokumen" name="kelengkapan_dokumen[]" class="form-control input-width-large"></textarea>'+
			'</td>'+
			
		'</tr>';



$("#body-claim").append(html);

$("#index").val(indexi);

});

});

</script>

<div class="form">

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'trx-receipt-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

    <!--<p class="help-block">Fields with <span class="required">*</span> are required.</p>-->

    <?php echo $form->errorSummary($model); ?>

            <div class="row">
	<div class="col-md-12">
				<div class="widget box">
				<div class="widget-header">

				<h4><i class="icon-reorder"></i>No Polis : </h4>
				<div class="controls">
				<div class="input-group">
				 <input id="policy_no" class="form-control input-width-large" type="text" name="policy_no">
						<a class="btn btn-default btn-warning" href="#myModal" data-toggle="modal" style="float:right">FIND</a>
					<input type="hidden" name="HistClaim[policy_no]" id="policy_no_hist_claim" />
					<input type="hidden" name="HistClaim[mst_client_id]" id="mst_client_id" />
					<input type="hidden" name="HistClaim[reg_policy_id]" id="reg_policy_id" />
					<input type="hidden" name="HistClaim[type_reg_policy]" id="type_reg_policy" />
					<input type="hidden" name="HistClaim[file]" id="nama_file" />
					<input type="hidden" name="index" id="index" value="10" />
				</div>
				</div>

				

				<h3><i class="icon-reorder"></i>Status </h3>
				<div class="controls">
				<div class="input-group">
				 <h4>New Claim</h4>
				</div>
				</div>
				<br />

				<a href="#" id="btn_tambah" class="btn btn-sm btn-primary">Tambah Claim</a>
				
				<div style="text-align:right;">
				<a href="#" id="btn_lihat_benefit" class="btn btn-sm btn-primary">Lihat Benefit Klien</a>&nbsp;
				<!--<a href="#" id="btn_lihat_data_peserta" class="btn btn-sm btn-primary">Lihat Data Peserta</a>-->
				</div>

				</div>
				

				<div class="widget-content no-padding">

				<table class="table table-striped table-bordered table-hover table-checkable table-responsive">
	<thead>
		<tr>
			<th>No</th>
			<th>Nama Karyawan</th>
			<th>Nama Peserta</th>
			<th>No Reg</th>
			<th>Tgl Pengobatan</th>
			<th>Manfaat</th>
			<th>Jumlah Claim</th>
			<th>Jumlah Dibayar</th>
			<th>Tgl Pembayaran</th>
			<th>Keterangan</th>
			<th>Kelengkapan Dokumen</th>
		</tr>
	</thead>
	<tbody id="body-claim">
		<?php 
		for($i=1;$i<=10;$i++){
		?>
		<tr>
			<td><span id="nomor"><?php echo $i; ?></span></td>
			<td>
				<?php echo $form->textField($modelAnggota,'karyawan', array('class'=>'form-control input-width-medium','name'=>'karyawan[]')); ?>
			</td>

			<td>
				<?php echo $form->textField($modelAnggota,'peserta', array('class'=>'form-control input-width-medium','name'=>'peserta[]')); ?>
			</td>

			<td>
				<?php echo $form->textField($modelAnggota,'no_reg', array('class'=>'form-control input-width-small','name'=>'no_reg[]')); ?>
			</td>


			<td>
				<?php echo $form->textField($modelAnggota,'tgl_claim', array('class'=>'form-control input-width-small','data-mask'=>"99-99-9999", 'name'=>'tgl_claim[]')); ?>
				<div id="tgl_claim2<?php echo $i; ?>" style="text-align:center;">
				s/d
				<?php echo $form->textField($modelAnggota,'tgl_claim2', array('class'=>'form-control input-width-small','data-mask'=>"99-99-9999", 'name'=>'tgl_claim2[]')); ?>
				</div>
			</td>

			<td>
			<?php echo $form->dropDownList($modelAnggota, 'plan', array('IP' => "IP",
			'IP' => "IP",
			'OP' => "OP",
			'MA' => "MA",
			'VS' => "VS",
			'DE' => "DE",
			'KECELAKAAN' => "KECELAKAAN",
			'JIWA' => "JIWA",
			'MEDEVAC' => "MEDEVAC",
			'JENAZAH' => "JENAZAH"
			),array('class'=>'form-control input-width-small','name'=>'plan[]', 'index'=>$i)); ?>
			</td>

			<td>
				<?php echo $form->textField($modelAnggota,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>

			<td>
				<?php echo $form->textField($modelAnggota,'jumlah_dibayar', array('class'=>'form-control input-width-small','name'=>'jumlah_dibayar[]')); ?>
			</td>

			<td>
				<?php echo $form->textField($modelAnggota,'tgl_pembayaran', array('class'=>'form-control input-width-small','data-mask'=>"99-99-9999", 'name'=>'tgl_pembayaran[]')); ?>
			</td>

			<td>
				<?php echo $form->textArea($modelStatus,'remarks', array('class'=>'form-control ','name'=>'remarks[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($modelStatus,'kelengkapan_dokumen', array('class'=>'form-control','name'=>'kelengkapan_dokumen[]')); ?>
			</td>
		</tr>



		<?php 
		}
		?>


		
	</tbody>
</table>	



							</div>
						</div>
					</div>
	</div>

        <div class="form-actions">
        <?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
		    'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
		    'size'=>TbHtml::BUTTON_SIZE_LARGE,
		)); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->


	<div id="myModal" class="modal fade in" style="display: none;" aria-hidden="false">
												<div class="modal-dialog" style="width:800px;">
													<div class="modal-content">
														<div class="modal-header">
															<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
															<h4 class="modal-title">Pilih Client</h4>
														</div>
														<div class="modal-body">
															
															<?php echo $this->renderPartial('_viewClient', array('model'=>$modelClient, 'modelClientNonHealth'=>$modelClientNonHealth));  // I need $productId to by dynamic related to link 
                ?> 
														</div>
														<div class="modal-footer">
															<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
															<button id="btnTest" data-dismiss="modal" class="btn btn-primary" type="button">Pilih</button>
														</div>
													</div><!-- /.modal-content -->
												</div><!-- /.modal-dialog -->
	</div>




